package logic

import (
	"context"
	"zye1/user_srv/model/redis"

	"zye1/user_srv/internal/svc"
	"zye1/user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type SmsCodeLimitLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewSmsCodeLimitLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SmsCodeLimitLogic {
	return &SmsCodeLimitLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *SmsCodeLimitLogic) SmsCodeLimit(in *user.SmsCodeLimitRequest) (*user.SmsCodeLimitResponse, error) {
	// todo: 短信限流

	smsLimit := redis.SmsCodeLimit(in.Mobile)

	return &user.SmsCodeLimitResponse{SmsLimit: smsLimit}, nil
}
